package com.zhu.responder.pojo;

import lombok.Data;

import java.io.Serializable;

@Data
public class R<T> implements Serializable {
    private Integer code;

    private String msg;

    private T data;

    R() {
    }

    R(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> R<T> ok(){
        return new R<T>(200,"成功",null);
    }

    public static <T> R<T> ok(T data){
        return new R<T>(200,"成功",data);
    }

    public static <T> R<T> ok(Integer code,String msg,T data){
        return new R<T>(code,msg,data);
    }

    public static <T> R<T> error(String msg){
        return new R<T>(-1,msg,null);
    }

    public static <T> R<T> error(Integer code,String msg){
        return new R<T>(code,msg,null);
    }

    public static <T> R<T> error(Integer code,String msg,T data){
        return new R<T>(code,msg,data);
    }


}